package test;

import java.util.ArrayList;

public class BackUpClass 
{
	private ArrayList<String> arlCodeFile;
	
	public void TestMain()
	{
		//**************************************************************
	    //scan results by scope Once
//	    for (int i = 0; i < strsLocation.length; i++)
//	    {
//	    	strRtn = strRtn + scanByScopeOnce(pCntToken.getToken(), pTokenWord, strsLocation[i]);
//	    }
	    //**************************************************************
	}
	
	/*
	 * Function: Scan tokens between nearest two ";", but only once(first location of current abbreviation)
	 * Input: pToken -> Current abbreviation
	 * 		  pTokenWord -> Current abbreviation (alphabets only)
	 * 		  pLoc -> Line number in code file
	 * Output: strRtn -> Analyze result
	 */
	public String scanByScopeOnce(String pToken, String pTokenWord, String pLoc)
	{
		String strRtn = "";
		String strCodeLine = arlCodeFile.get(Integer.parseInt(pLoc.trim()) - 1);
		
		String[] strCodeTokens = strCodeLine.split(" ");
		int intIndex = 0;
		
		// find the abbreviation's location in current code line
		for (int i = 0; i < strCodeTokens.length; i++)
		{
			if (strCodeTokens[i].equals(pToken))
			{
				intIndex = i;
				break;
			}
		}
		
		// get sub string by searching the nearest ";"
		int intFront = intIndex;
		int intRear = intIndex;
		
		while (!strCodeTokens[intFront].contains(";") && intFront >= -1)
		{
			intFront --;
		}		
		while (!strCodeTokens[intRear].contains(";") && intRear <= strCodeTokens.length)
		{
			intRear ++;
		}
		
		// strCnt -> sub string
		String strCnt = "";			
		for (int i = intFront + 1; i <= intRear; i++)
		{
			strCnt = strCnt + strCodeTokens[i] + " ";
		}
		
		//strRtn = AbbCombi(pTokenWord, strCnt);
		
		//*******************************************************
					
		//System.out.println();
		//System.out.println("[" + strCnt + "] Searching for [" + pToken + "]");
		//System.out.println("Result for token [" + pToken + "] is [" + strRtn + "]");
		
		//*******************************************************
		
		return strRtn;
	}
}
